﻿namespace TVersityDotNet.MediaLib
{
    using System.Collections.Generic;
    using System.Globalization;
    using System.Runtime.Serialization;

    [DataContractAttribute]
    public class SearchOptions : MediaLibOptions
    {
        /// <summary>
        /// The search query. It can be a collection of keywords or a full blown search expression as defined in the UPnP standard
        /// </summary>
        [DataMember]
        public string Query
        {
            get { return (string)this.PropertyBag.GetPropertyFromPropertyBag("q"); }
            set { this.PropertyBag.AddPropertyToPropertyBag("q", value); }
        }

        /// <summary>
        /// Constructor for SearchOptions
        /// It is expected that any specific search options will be set prior to sending this object
        /// </summary>
        /// <param name="query">The query string to search for.</param>        
        public SearchOptions(string query)
        {
            this.PropertyBag = new HelperTypes.PropertyBag();
            if (!string.IsNullOrEmpty(query))            
                this.Query = query.Replace(" ", "+");
            // This is the default format that is expected in the search response. Anything else will not be parsable.
            this.Format = TVersityResponse.DefaultFormat;
        }
    }
}
